package com.itheima.shop.decorator;

import com.itheima.shop.dao.ItemDao;
import com.itheima.shop.domain.Item;
import com.itheima.shop.domain.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @program: design
 * @description:
 * @author: zhanghz001
 * @create: 2020-12-15 12:17
 **/
@Component("orderMoneySum")
public class OrderMoneySum implements MoneySum {
    @Autowired
    private ItemDao itemDao;
    
    @Override
    public void money(Order order) {
        Item item = itemDao.findById(order.getItemId());
        //商品价格*购买数量
        int money = order.getNum() * item.getPrice();
        order.setMoney(money);
        order.setPaymoney(money);
    }
    
}
